package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.RechargeConfig;
import com.micro.modual.extension.RechargeConfigExtension;
import com.micro.modual.mapper.RechargeConfigMapper;
import com.micro.modual.model.bo.rechargeconfig.RechargeConfigBO;
import com.micro.modual.service.RechargeConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>充值配置表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("rechargeConfigService")
public class RechargeConfigServiceImpl extends AbstractBasicsServiceImpl<RechargeConfig,Long> implements RechargeConfigService {

    @Autowired
    private RechargeConfigMapper rechargeConfigMapper;

    /**
     * <h2>新增充值配置表详情</h2>
     * @param rechargeConfigBO {@link RechargeConfigBO} 充值配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addRechargeConfig(RechargeConfigBO rechargeConfigBO) {
        RechargeConfig rechargeConfig = RechargeConfigExtension.converAddRechargeConfig(rechargeConfigBO);
        rechargeConfigMapper.insertSelective(rechargeConfig);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改充值配置表详情</h2>
     * @param rechargeConfigBO  {@link RechargeConfigBO} 充值配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editRechargeConfig(RechargeConfigBO rechargeConfigBO) {
        RechargeConfig rechargeConfig = RechargeConfigExtension.converEditRechargeConfig(rechargeConfigBO);
        rechargeConfigMapper.updateByPrimaryKeySelective(rechargeConfig);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除充值配置表信息</h2>
     * @param id  充值配置表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteRechargeConfig(Long id) {
        rechargeConfigMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
